Return to doc.sitecore.com

Comparing String Suffixes

To determine if one string value ends with another string value, use code such as the following. 

This example uses variables for clarity, but they are not required.

<xsl:variable name="somestring" select='this text ends with .'" />

<xsl:variable name="check" select="." />

<xsl:if test="$check = substring( $somestring, 1 + string-length( $somestring ) - string-length( $check ))">

  <xsl:value-of select="$somestring" /> ends with "<xsl:value-of select="$check" />".

</xsl:if>